<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>NaN类型和数值类型转换</title>
</head>
<body>
    <script>
        console.log(Number("kflsld"));
        console.log('kfgfg' / 2);

        // NaN是不可以跟自己比较的
        console.log(NaN == NaN);

        // 判断是否是NaN
        console.log(Number.isNaN('fsfg' / 2));//true
        console.log(Object.is('fsfg' / 2,NaN))//true



        // Boolean类型转化为数值类型
        console.log(Number(true));//1
        console.log(Number(false));//0

        // 字符串类型转化为数字类型
        let str = '563456';
        console.log(Number(str));
        let string = '3245.3453dfsgfhdfhg';
        console.log(parseInt(string));
        console.log(parseFloat(string));


        let arr = [];
        console.log(Number(arr));//0
        let arr1 = [1];
        console.log(Number(arr1));//1
        let arr2 = [1,2,3];
        console.log(Number(arr2));//NaN


        let obj = {};
        console.log(Number(obj));//NaN
        console.log(Number({     //435
            valueOf: function () {
                return  435;
            }
        }))
    </script>
</body>
</html>